package de.tudresden.st.cbse.util;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import de.tudresden.st.cbse.calendar.RemoteCalendarManager;
import de.tudresden.st.cbse.calendar.user.RemoteUserManager;

public class RemoteLookup {

    private RemoteLookup() {
    }

    public static RemoteUserManager getUserManager() throws NamingException {
        final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        final Context context = new InitialContext(jndiProperties);

        return (RemoteUserManager) context.lookup("ejb:/appointment-management/UserManagerBean!" + RemoteUserManager.class.getName());
    }

    public static RemoteCalendarManager getCalendarManager() throws NamingException {
        final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        final Context context = new InitialContext(jndiProperties);

        return (RemoteCalendarManager) context.lookup("ejb:/appointment-management/CalendarManagerBean!" + RemoteCalendarManager.class.getName());
    }
}
